package com.my.swas.sso.common.config.properties;

import com.my.swas.common.utils.ehcache.EhcacheUtils;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Description:
 * @author: :MaYong
 */
@Configuration
@ConfigurationProperties(prefix = SSOProperties.SSO_PROPS)
public class SSOProperties {
    public static final String SSO_PROPS = "sso.props";
    private String cookieDomain;
    private String verifyCount;
    private String ehcacheRootDir;

    public String getCookieDomain() {
        return cookieDomain;
    }

    public void setCookieDomain(String cookieDomain) {
        this.cookieDomain = cookieDomain;
    }

    public String getVerifyCount() {
        return verifyCount;
    }

    public void setVerifyCount(String verifyCount) {
        this.verifyCount = verifyCount;
    }

    public String getEhcacheRootDir() {
        return ehcacheRootDir;
    }

    public void setEhcacheRootDir(String ehcacheRootDir) {
        this.ehcacheRootDir = ehcacheRootDir;
    }

    /**
     * bean必须有返回值 所以这里返回一个0.实际无任何意义
     * @return
     */
    @Bean
    public int initStatic(){
        //静态方法需要调用，这里进行预设值
        EhcacheUtils.setRootDir(getEhcacheRootDir());
        return 0;
    }
}
